<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                template="/templates/mainLayout.xhtml">

    <ui:define name="title">Sửa thông tin tài khoản</ui:define>
    <ui:define name="idleMonitor">
        <h:form id="monitorForm" prependId="false">
            <p:idleMonitor timeout="#{profileBean.conversation.getTimeout()}" onidle="idleDialog.show();" 
                           onactive='window.location = "profile.jsf";' rendered="#{!profileBean.conversation.isTransient()}"/>

            <p:dialog header="Thông báo" resizable="false" widgetVar="idleDialog" modal="true" width="400">
                <h:outputText value="Phiên làm việc trên trang này đã hết hạn" />
            </p:dialog>
        </h:form>
    </ui:define>
    <ui:define name="content">
        <f:event type="preRenderView" listener="#{profileBean.preEditAction()}" />
        <h:form id="mainForm">
            <p:panel header="Sửa thông tin tài khoản">
                <p:messages id="msgs"/>
                <p:toolbar style="margin-bottom: 10px; margin-top: 10px;" rendered="#{profileBean.user != null}">
                    <p:toolbarGroup align="left">  
                        <p:commandButton value="Cập nhật" action="#{profileBean.updateAction()}" update="mainForm"/>
                        <p:commandButton value="Hủy" action="#{profileBean.cancelAction()}" immediate="true"/>
                        <p:commandButton type="reset" value="Nhập lại"/>
                    </p:toolbarGroup>
                </p:toolbar>
                
                <h:panelGrid styleClass="panelGrid" columnClasses="ui-state-default labelCol, ui-widget-content" 
                             columns="2" cellpadding="5" width="100%" rendered="#{profileBean.user != null}">  
                    <h:outputLabel for="fullName" style="display: inline; float: right; padding-right: 5px;" value="Tên đầy đủ " />  
                    <p:inputText value="#{profileBean.user.fullName}" id="fullName" label="Tên đầy đủ" maxlength="100"/>
                </h:panelGrid>

                <p:toolbar style="margin-bottom: 10px; margin-top: 10px;" rendered="#{profileBean.user != null}">
                    <p:toolbarGroup align="left">  
                        <p:commandButton value="Cập nhật" action="#{profileBean.updateAction()}" update="mainForm"/>
                        <p:commandButton value="Hủy" action="#{profileBean.cancelAction()}" immediate="true"/>
                        <p:commandButton type="reset" value="Nhập lại"/>
                    </p:toolbarGroup>
                </p:toolbar>
            </p:panel>
        </h:form>
    </ui:define>
</ui:composition>